package com.servlet;

import com.dao.imp.FindAllType;
import com.entity.ParentType;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.io.IOException;
import java.util.List;

/**
 * @author Mathison
 * @Title: ${NAME}
 * @Package: ${PACKAGE_NAME}
 * @Description: TODO
 * @date 2021/11/21 15:25
 **/

@WebServlet(name = "GetGoodTypeServlet", value = "/GetGoodTypeServlet")
public class GetParentTypeServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        FindAllType findAllType = new FindAllType();
        List<ParentType> parentTypeList = findAllType.getParentType();
        JSONArray json = JSONArray.fromObject(parentTypeList);

        response.getWriter().print(json);
    }
}
